﻿// Author:					HungNM
// Created:					27-07-2012
// Last Modified:			27-07-2012
//

using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using eProject.Data;

namespace eProject.Business
{
    public class UserPermissions : IEquatable<UserPermissions>
    {
        #region Properties

	    private long _userId;
	    public long UserId {
            get { return _userId; }
		    set {
			    // To ensure that the Prod object will be re-created
			    _user = null;
                _userId = value;
		    }
	    }

	    private Users _user = null;
	    public Users User {
		    get {
			    // Lazy initialization - the object won't be created until it is needed
			    if (_user == null) {
				    _user = new Users(UserId);
			    }
			    return _user;
		    }
	    }

	    #endregion

        // UserRoles constructor just needs a userId
        public UserPermissions(long userId)
        {
            this.UserId = userId;
	    }

	    /**
	     * Equals() - Needed to implement the IEquatable interface
	     *    Tests whether or not this item is equal to the parameter
	     *    This method is called by the Contains() method in the List class
	     *    We used this Contains() method in the ShoppingCart AddItem() method
	     */
        public bool Equals(UserPermissions userRoles)
        {
            return userRoles.UserId == this.UserId;
	    }
    }
}
